package com.qtt.app.service.impl;

import com.qtt.app.entity.AppStudyHistory;
import com.qtt.app.entity.AppViewsRecord;
import com.qtt.app.entity.CourseClass;
import com.qtt.app.mapper.AppViewsRecordMapper;
import com.qtt.app.service.AppViewsRecordService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class AppViewsRecordImpl implements AppViewsRecordService {
    @Autowired
    AppViewsRecordMapper appViewsRecordMapper;


    @Override
    public List<AppViewsRecord> getMyViewsRecordAll(Long userId) {
        List<AppViewsRecord> entities = appViewsRecordMapper.getMyViewsRecordAll(userId);
        return entities;
    }

    @Override
    public int addViewCourseRecourd(AppViewsRecord requestData) {
        requestData.setGmtCreate(new Date());
        requestData.setGmtModified(new Date());
        int addFlag = appViewsRecordMapper.insertSelective(requestData);
        int id=0;
        if(addFlag!=0){
             id = appViewsRecordMapper.getLastId();
        }
        else {
            id= 0;
        }

        return id;
    }

    @Override
    public int deleteSchedule(String deleteTime) {
//        String time =deleteTime+"%";
        int flag = appViewsRecordMapper.deleteSchedule(deleteTime);
        return flag;
    }


}
